package com.tek.ding.faceding.presenter.camera;

import com.tek.ding.faceding.base.BasePresenter;

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.schedulers.Schedulers;

public class CameraPresenter extends BasePresenter<CameraContract.ICameraModel, CameraContract.CameraView> {

    public CameraPresenter(CameraContract.ICameraModel model, CameraContract.CameraView view) {
        super(model, view);
    }

    public void addFaceEntity2(String storeUid, String memberUid, String photoUrl) {
//        model.addFaceEntity2(storeUid, memberUid, photoUrl)
//                .compose(RxHttpResponseCompat.compatResult())
//                .subscribe(new ProgressDialogObservable<BaseBean<String>>(context, view) {
//                    //不显示提示框
//                    @Override
//                    protected boolean isShowDialog() {
//                        return false;
//                    }
//
//                    @Override
//                    public void onNext(@NonNull BaseBean<String> baseBean) {
//                        if (baseBean != null) {
//                            view.addFaceEntityOk(baseBean);
//                        }
//                    }
//                });

        model.addFaceEntity2(storeUid, memberUid, photoUrl)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(bean -> {
                    if (bean != null) {
                        view.addFaceEntityOk(bean);
                    }
                }, throwable -> {

                });
    }

    public void toShopFace2(String storeUid, String faceImg) {
//        model.toShopFace2(storeUid, faceImg)
//                .compose(RxHttpResponseCompat.compatResult())
//                .subscribe(new ProgressDialogObservable<BaseBean<String>>(context, view) {
//                    //不显示提示框
//                    @Override
//                    protected boolean isShowDialog() {
//                        return false;
//                    }
//
//                    @Override
//                    public void onNext(@NonNull BaseBean<String> baseBean) {
//                        if (baseBean != null) {
//                            view.toShopFaceOk(baseBean);
//                        }
//                    }
//                });
        model.toShopFace2(storeUid, faceImg)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(bean -> {
                    if (bean != null) {
                        view.toShopFaceOk(bean);
                    }
                }, throwable -> {

                });
    }

    public void leaveShopFace2(String storeUid, String faceImg) {
//        model.leaveShopFace2(storeUid, faceImg)
//                .compose(RxHttpResponseCompat.compatResult())
//                .subscribe(new ProgressDialogObservable<BaseBean<String>>(context, view) {
//                    //不显示提示框
//                    @Override
//                    protected boolean isShowDialog() {
//                        return false;
//                    }
//
//                    @Override
//                    public void onNext(@NonNull BaseBean<String> baseBean) {
//                        if (baseBean != null) {
//                            view.leaveShopFaceOk(baseBean);
//                        }
//                    }
//                });

        model.leaveShopFace2(storeUid, faceImg)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(bean -> {
                    if (bean != null) {
                        view.leaveShopFaceOk(bean);
                    }
                }, throwable -> {

                });
    }

    public void getMemberByFaceImg2(String storeUid, String faceImg) {
//        model.getMemberByFaceImg2(storeUid, faceImg)
//                .compose(RxHttpResponseCompat.compatResult())
//                .subscribe(new ProgressDialogObservable<BaseBean<Members>>(context, view) {
//                    //不显示提示框
//                    @Override
//                    protected boolean isShowDialog() {
//                        return false;
//                    }
//
//                    @Override
//                    public void onNext(@NonNull BaseBean<Members> baseBean) {
//                        if (baseBean != null) {
//                            view.getMemberByFaceImgOk(baseBean);
//                        }
//                    }
//                });

        model.getMemberByFaceImg2(storeUid, faceImg)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(bean -> {
                    if (bean != null) {
                        view.getMemberByFaceImgOk(bean);
                    }
                }, throwable -> {

                });
    }

}
